package com.thomas.framework.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.JSONLibDataFormatSerializer;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;

/**
 * Created by taohj on 2014/4/17.
 */
public  class JsonUtil {


    private static final SerializeConfig config;


    private static final SerializerFeature[] features = { SerializerFeature.WriteMapNullValue, //
            SerializerFeature.WriteNullListAsEmpty, //
            SerializerFeature.WriteNullNumberAsZero, //
            SerializerFeature.WriteNullBooleanAsFalse, //
            SerializerFeature.WriteNullStringAsEmpty, //
            SerializerFeature.BrowserCompatible,
            SerializerFeature.DisableCircularReferenceDetect

    };

    static {
        config = new SerializeConfig();
        config.put(java.util.Date.class, new JSONLibDataFormatSerializer()); //
        config.put(java.sql.Date.class, new JSONLibDataFormatSerializer()); //
    }


    public static String toString(Object object){

           return JSON.toJSONStringWithDateFormat(object,"yyyy-MM-dd", features);
    }




}
